import { createApp } from './vue.js';

// const { createApp } = Vue;
createApp({
    data() {
        return {
            list: [
                {
                    name: '茄子',
                    discuss: '住在山里面，真不错~',
                    upvote: 999,
                    date: new Date().toLocaleDateString(),
                },
            ],
            release: '',
        };
    },
    methods: {
        discussFn() {
            if (this.release !== '') {
                this.list.push({
                    name: '茄子',
                    discuss: this.release,
                    upvote: '0',
                    date: new Date().toLocaleDateString(),
                });
            }
            this.release = '';
        },
        listFn(item) {
            item.upvote++;
        },
        topFn(item) {
            const index = this.list.indexOf(item);
            if (index !== -1) {
                this.list.splice(index, 1);
            }
            this.list.unshift(item);
        },
        deleteFn(item) {
            // console.log(item);
            const index = this.list.indexOf(item);
            if (index !== -1) {
                this.list.splice(index, 1);
            }
        },
    },
}).mount('#app');
